﻿using System;

using log4net;
using log4net.Config;

namespace MiniSched.Logging.Log4Net {

    public class Log4NetLogFactory : MiniSchedLogFactory {

        private bool IsInitialized;

        private void Initialize() {
            XmlConfigurator.Configure();
        }

        private void EnsureInitialized() {
            if (IsInitialized == false) {
                Initialize();
                IsInitialized = true;
            }
        }

        public override MiniSchedLog CreateLogFor(Type type) {
            EnsureInitialized();
            return new Log4NetLog(LogManager.GetLogger(type));
        }
    }
}
